﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using NRCP.BusinessLogicLayer;
using NRCP.BusinessEntities;

namespace NRCP.MetaData
{
    public partial class Farmer_Add : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
        }

        private void ClearPage()
        {
            tbName.Text = "";
            tbRegistrationNo.Text = "";
            tbAddress.Text = "";
        }

        protected void bSave_Click(object sender, EventArgs e)
        {
            FarmerBLL bll = new FarmerBLL();
            Farmer farmer = new Farmer();
            try
            {
                farmer.Name = tbName.Text.Trim();
                farmer.RegistrationNo = tbRegistrationNo.Text.Trim();
                farmer.Address = tbAddress.Text.Trim();
                bll.CreateNewFarmer(farmer);
                rm.SetSuccessMessage("Add Farmer Successful.");
                ClearPage();
            }
            catch (Exception ex)
            {
                rm.SetFailMessage("Failed To Add Farmer. " + ex.Message);
            }
        }
    }
}